package src.Sixteen;

import java.net.InetAddress;
import java.net.UnknownHostException;

public class Address {

    public static void main(String[] args) {
        InetAddress ip;
        try {
            ip = InetAddress.getLocalHost();
            String hostName = ip.getHostName();
            String hostAddress = ip.getHostAddress();
            System.out.println("本地主机名："+hostName);
            System.out.println("本地ip地址："+hostAddress);
        } catch (UnknownHostException e) {
            throw new RuntimeException(e);
        }
    }
}
